/**
 * Test cases for removeEvent
 * 
 * Note: trying to remove an event with a binded function will:
 *   - fail under Firefox;
 *   - fail under Opera;
 *   - succeed under MSIE (!)
 */

// function: success
function Test1()
{
	alert('I will never be displayed.');
}
$(document.body).addEvent('click', Test1);
$(document.body).removeEvent('click', Test1);


// js object + bind: fails!
function Test2()
{
	function start()
	{
		$(document.body).addEvent('click',    this.test.bind(this));
		$(document.body).removeEvent('click', this.test.bind(this));
	}
	
	function test()
	{
		alert("I shouldn't be displayed.");
	}
	
	this.start = start;
	this.test  = test;
};
new Test2().start();


// mootools object: success
var Test3 = new Class(
{
	initialize: function()
	{
		$(document.body).addEvent('click',    this.test);
		$(document.body).removeEvent('click', this.test);
	},
	
	test: function()
	{
		alert("I will never be displayed.");
	}
});
new Test3();


// mootools object + bind: fails!
var Test4 = new Class(
{
	initialize: function()
	{
		$(document.body).addEvent('click',    this.test.bind(this));
		$(document.body).removeEvent('click', this.test.bind(this));
	},
	
	test: function()
	{
		alert("I will never be displayed on MSIE, but I will on any other browser :(");
	}
});
new Test4();
